package com.huqing.icu.rentreport.dao;

import com.huqing.icu.rentreport.dto.ReportRecordDto;
import com.huqing.icu.rentreport.dto.ReportRecordQueryDto;
import com.huqing.icu.rentreport.mapper.ReportRecordMapper;
import com.huqing.icu.rentreport.model.ReportRecord;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ReportRecordDao {

    @Resource
    private ReportRecordMapper reportRecordMapper;

    public Integer getNumByCondition(ReportRecordQueryDto queryDto) {
        return reportRecordMapper.getNumByCondition(queryDto);
    }

    public List<ReportRecordDto> selectByCondition(ReportRecordQueryDto queryDto) {
        return reportRecordMapper.selectByCondition(queryDto);
    }

    public ReportRecord selectById(Long id) {
        return reportRecordMapper.selectById(id);
    }

    public Integer save(ReportRecord reportRecord) {
        if (reportRecord.getId() == null) {
            reportRecordMapper.insert(reportRecord);
        } else {
            reportRecordMapper.updateById(reportRecord);
        }
        return 1;
    }

    public Integer insert(ReportRecord reportRecord) {
        return reportRecordMapper.insert(reportRecord);
    }

    public Integer updateById(ReportRecord reportRecord) {
        return reportRecordMapper.updateById(reportRecord);
    }

    public Integer deleteById(Long id) {
        return reportRecordMapper.deleteById(id);
    }
}
